package 多接口;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2022-07-01
 * Time: 11:42
 */
//抽象类
abstract class Animal{
    public String name;
    public int age;

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }
    public abstract void eat();
}
//跑
interface IRuning{
    void run();
}
//飞
interface IFlying{
    void fly();
}
//游泳
interface ISwimming{
    void swimming();
}

class Dog extends Animal implements IRuning,ISwimming{
    public Dog(String name, int age) {
        super(name, age);
    }

    @Override
    public void eat() {
        System.out.println(name+"正在吃狗粮");
    }

    @Override
    public void run() {
        System.out.println(name+"正在四条腿跑");
    }

    @Override
    public void swimming() {
        System.out.println(name+"正在狗刨");

    }
}
class Bird extends Animal implements IRuning,IFlying{
    public Bird(String name, int age) {
        super(name, age);
    }

    @Override
    public void eat() {
        System.out.println(name+"正在吃鸟粮");

    }

    @Override
    public void run() {
        System.out.println(name+"正在两条细腿跳着跑");
    }

    @Override
    public void fly() {
        System.out.println(name+"两只小翅膀正在飞");

    }
}
class Duck extends Animal implements IRuning,IFlying,ISwimming{
    public Duck(String name, int age) {
        super(name, age);
    }

    @Override
    public void eat() {
        System.out.println(name+"鸭子正在吃鸭粮");
    }

    @Override
    public void run() {
        System.out.println(name+"两只大脚掌正在跑");
    }

    @Override
    public void fly() {
        System.out.println(name+"两只大翅膀在飞");
    }

    @Override
    public void swimming() {
        System.out.println(name+"两只大脚掌在游泳");

    }
}
public class Test {
   //抽象类引用
    public static void eat(Animal animal){
        animal.eat();
    }
    //接口类引用
    public static void run(IRuning iRuning){
        iRuning.run();
    }
    public static void fly(IFlying iFlying){
        iFlying.fly();
    }
    public static void swim(ISwimming iSwimming){
      iSwimming.swimming();
    }
    public static void main(String[] args) {
        eat(new Dog("边牧",4));
        eat(new Bird("鹦鹉",1) );
        eat(new Duck("唐老鸭",15));
        System.out.println("======================");
        run(new Dog("边牧",4));
        run(new Bird("鹦鹉",1) );
        run(new Duck("唐老鸭",15));
        System.out.println("======================");
        fly(new Bird("鹦鹉",1) );
        fly(new Duck("唐老鸭",15));
        System.out.println("=======================");
        swim(new Dog("边牧",4));
        swim(new Duck("唐老鸭",15));
    }
}
